<template>
  <div v-if="Object.keys(detailInfo).length >= 1" class="goods-info">
    <div class="info-desc">
      <div class="start"></div>
      <div class="desc">{{detailInfo.desc}}</div>
      <div class="end"></div>
    </div>
    <div class="info-key">{{detailInfo.key}}</div>
    <div class="info-list">
      <img v-for="(item,index) in detailInfo.list" :src="item" alt="" :key="index" @load="imageLoad">
    </div>
  </div>
</template>

<script>
  export default {
    name: "DetailGoodsInfo",
    props: {
      detailInfo: {
        type: Object,
        default(){
          return {};
        }
      }
    },
    data(){
      return {
        currentIndex: 0,
        imagesLength: 0
      };
    },
    methods:{
      imageLoad(){
        if (++this.currentIndex === this.imagesLength - 1){
          this.$emit("imageLoad");
        }
      }
    },
    watch: {
      detailInfo(){
        this.imagesLength = this.detailInfo.list.length;
      }
    }
  };
</script>

<style scoped>
  .goods-info{
    margin-top: 10px;
    padding: 20px 10px;
    background-color: white;
  }
  .info-desc .start,.info-desc .end{
    width: 90px;
    height: 1px;
    background-color: #333333;
    position: relative;
  }
  .info-desc .start{
    float: left;
  }
  .info-desc .end{
    float: right;
  }

  .info-desc .start::before, .info-desc .end::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    background-color: #333;
    bottom: 0;
  }
  .info-desc .end::after {
    right: 0;
  }
  .info-desc .desc {
    padding: 15px 0;
    font-size: 14px;
  }
  .info-key{
    color: #333333;
    font-size: 15px;
    margin: 10px 0 10px 0;
  }
  .info-list img{
    width: 100%;
  }
</style>
